package com.hongkuncheng.cms.model;

import javax.persistence.*;
import java.util.List;
import java.util.Objects;
import java.io.Serializable;

@Entity
public class Checknode implements Serializable {
    protected int id;
    protected String name;
    protected boolean singleaudit;
    protected boolean canedit;
    protected boolean groupbydepart;
    protected int sort;
    protected List<Article> articles;
    protected ChecknodeType checknodeType;
    protected Checkflow checkflow;
    protected List<ChecknodeReAdmin> checknodeReAdmins;
    protected List<Checkrecord> checkrecords;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "name", nullable = false, length = 255)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "singleaudit", nullable = false)
    public boolean isSingleaudit() {
        return singleaudit;
    }

    public void setSingleaudit(boolean singleaudit) {
        this.singleaudit = singleaudit;
    }

    @Basic
    @Column(name = "canedit", nullable = false)
    public boolean isCanedit() {
        return canedit;
    }

    public void setCanedit(boolean canedit) {
        this.canedit = canedit;
    }

    @Basic
    @Column(name = "groupbydepart", nullable = false)
    public boolean isGroupbydepart() {
        return groupbydepart;
    }

    public void setGroupbydepart(boolean groupbydepart) {
        this.groupbydepart = groupbydepart;
    }

    @Basic
    @Column(name = "sort", nullable = false)
    public int getSort() {
        return sort;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Checknode checknode = (Checknode) o;
        return id == checknode.id &&
                singleaudit == checknode.singleaudit &&
                canedit == checknode.canedit &&
                groupbydepart == checknode.groupbydepart &&
                sort == checknode.sort &&
                Objects.equals(name, checknode.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, singleaudit, canedit, groupbydepart, sort);
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "checknode")
    public List<Article> getArticles() {
        return articles;
    }

    public void setArticles(List<Article> articles) {
        this.articles = articles;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "type_id", referencedColumnName = "id", nullable = false)
    public ChecknodeType getChecknodeType() {
        return checknodeType;
    }

    public void setChecknodeType(ChecknodeType checknodeType) {
        this.checknodeType = checknodeType;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "checkflow_id", referencedColumnName = "id", nullable = false)
    public Checkflow getCheckflow() {
        return checkflow;
    }

    public void setCheckflow(Checkflow checkflow) {
        this.checkflow = checkflow;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "checknode")
    public List<ChecknodeReAdmin> getChecknodeReAdmins() {
        return checknodeReAdmins;
    }

    public void setChecknodeReAdmins(List<ChecknodeReAdmin> checknodeReAdmins) {
        this.checknodeReAdmins = checknodeReAdmins;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "checknode")
    public List<Checkrecord> getCheckrecords() {
        return checkrecords;
    }

    public void setCheckrecords(List<Checkrecord> checkrecords) {
        this.checkrecords = checkrecords;
    }
}
